#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int l, m, j, i, x, k = 0, n, sum = 0;
	cin >> n >> x;
	l = n;
	while (l) {
		m = l % 10;
		l /= 10;
		j = pow(10, k);
		if (x == 0) l--;
		if (m > x) l++;
		sum += l * j;
		if (m == x) sum += n % j + 1;
		k++;
	}
	cout << sum;
	return 0;
}